﻿using CaseManagerLibrary.Auth;
using PSDClient.Service;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace PSDClient
{
    public partial class FrmLogin : Form
    {
        public FrmLogin()
        {
            InitializeComponent();

            this.txtUserName.Text = "基地管理员";
            this.txtPassword.Text = "tianjian0572";
        }

        private void btnLogin_Click(object sender, EventArgs e)
        {
            string address = Setting.ApiServerAddress;
            var result = LoginService.Login(address, this.txtUserName.Text.Trim(), this.txtPassword.Text.Trim());

            if (result.success)
            {
                this.DialogResult = DialogResult.OK;
            }
            else
            {
                MessageBox.Show(result.message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }
    }
}
